This repository was archived by the owner on Mar 15, 2026. It is now read-only.
Add output_format discriminator to preview responses#32
Merged
Conversation
Implements the schema changes from adcontextprotocol/adcp#185 which adds a required output_format field to preview render responses. This discriminator field indicates whether preview_url, preview_html, or both are provided, improving validation performance by eliminating oneOf constraints. Changes: - Updated ADCP schemas from spec (preview-creative-response.json) - Regenerated Pydantic models with output_format enum (url/html/both) - Modified _generate_preview_variant() to set output_format based on which preview fields are provided - All 187 tests passing The output_format field is now required per spec: - "url": preview_url only (iframe-embeddable) - "html": preview_html only (direct embedding) - "both": both preview_url and preview_html provided 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Address code review feedback: - Fix error handling: raise ValueError instead of defaulting when neither preview_url nor preview_html is provided (fail fast approach) - Reorder conditional logic for better readability (url/html/both) - Update docstring to document output_format field behavior - Add test assertions to verify output_format discriminator values - Verify that only appropriate preview fields are present per mode Tests verify: - output_format="html" sets field and excludes preview_url - output_format="url" sets field and excludes preview_html - Both single and batch modes correctly set discriminator All 187 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the schema changes from adcontextprotocol/adcp#185 which adds a required
output_formatfield to preview render responses. This discriminator field indicates whetherpreview_url,preview_html, or both are provided, improving validation performance by eliminatingoneOfconstraints.Changes
output_formatenum (url/html/both)_generate_preview_variant()to setoutput_formatbased on which preview fields are providedThe
output_formatfield is now required per spec with values:url(iframe-embeddable),html(direct embedding), orboth(both formats provided).